﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CS322_V12.entities;
using System.IO;

namespace CS322_V12
{
    public partial class EvidencijaForm : Form
    {
        public EvidencijaForm()
        {
            InitializeComponent();
        }

        private void EvidencijaForm_Load(object sender, EventArgs e)
        {
            try
            {
                Student student1 = new Student(1, "1234500", "Zoran", "Polić", 1);
                lbxStudenti.Items.Add(student1.Ime + " " + student1.Prezime);
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message);
            }

            try
            {
                Student student5 = new Student(5, "1234503", "Vladimir", "Perić", 1);
                lbxStudenti.Items.Add(student5.Ime + " " + student5.Prezime);
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message);
            }


          
            tbxBrojStudenata.Text = Student.KolikoStudenata();



        }

        private void btnDodaj_Click(object sender, EventArgs e)
        {
            Random random = new Random();
        
            try
            {
                Student student = new Student(random.Next(10), tbxJmbg.Text, tbxStudentIme.Text, tbxStudentPrezime.Text, 1);
                lbxStudenti.Items.Add(student.Ime + " " + student.Prezime);
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void tbxJmbg_Validating(object sender, CancelEventArgs e)
        {

            int j;

            if (int.TryParse(tbxJmbg.Text, out j) == false )
            {
                errProvider.SetError(tbxJmbg, "JMBG mora sadrzati numericke karaktere");
                MessageBox.Show("JMBG mora sadrzati numericke karaktere", "Error");
                e.Cancel = true;

            }
            else errProvider.SetError(tbxJmbg, "");
               
        }

       
   
        

    }

   
   
    
}
